package main

import "fmt"

/**
方法继承
 */
type Person2 struct {
	name string
	age  int
}

func (t *Person2) PrintPerson2() {
	fmt.Println("Person 父类方法")
	fmt.Println(*t)
}
func (t *Person2) Print() {
	fmt.Println("Person 父类方法Print")
	fmt.Println(*t)
}

type Student2 struct {
	Person2
	xuehao int
}

func (t *Student2) PrintStudent2() {
	fmt.Println("Student2 子类方法")
	fmt.Println(*t)
	fmt.Printf("%p \n", t)
}

//重写父类同名方法
func (t *Student2) Print() {
	fmt.Println("Student2 子类方法Print")
	fmt.Println(*t)
}
func main() {
	stu1 := Student2{Person2{"hi", 22}, 22}
	fmt.Printf("%p \n", &stu1)
	stu1.PrintPerson2()
	stu1.PrintStudent2()

	stu1.Print()
	stu1.Person2.Print()
}
